#include<iostream>
#include<vector>
using namespace std;



int main() {
	int n, m, l, r;
	cin >> n;
	vector<int>nums(n+1);
	for (int i = 1; i <= n; i++) {
		cin >> nums[i];
		nums[i] += nums[i - 1];
	}
	cin >> m;
	for (int i = 1; i <= m; i++)
	{
		cin >> l >> r;
		cout << nums[r] - nums[l - 1] << endl;
	}
	
}